package com.mon4cc.simulation.dataranger;


import org.springframework.util.Assert;

import java.util.Random;

/**
 * @author Ping
 * @date 2022/12/20 16:35
 **/
public class DoubleRanger implements DataRanger {
    private double left ;
    private double right ;
    private Random rand = new Random(System.currentTimeMillis()) ;

    public DoubleRanger(double left, double right) {
        this.left = left;
        this.right = right;
       Assert.state(right > left, "Double ranger should be with correct right and left.");
    }

    @Override
    public Object nextValue() {
        return left + ((right - left ) * rand.nextDouble());
    }
}
